//
//  AllCell.m
//  shiHuo
//
//  Created by zhiyou on 16-4-20.
//  Copyright (c) 2016年 zhiyou. All rights reserved.
//

#import "AllCell.h"

@implementation AllCell

- (void)awakeFromNib {
    // Initialization code
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.backgroundColor = [UIColor whiteColor];
        _imgView = [[UIImageView alloc] init];
        [self addSubview:_imgView];
        _atitleLab = [[UILabel alloc] init];
        _atitleLab.numberOfLines = 0;
        _atitleLab.font = [UIFont systemFontOfSize:14];
        [self addSubview:_atitleLab];
        _subTitleLab = [[UILabel alloc] init];
        _subTitleLab.textColor = [UIColor redColor];
        _subTitleLab.font = [UIFont systemFontOfSize:12];
        [self addSubview:_subTitleLab];
        _businessLab = [[UILabel alloc] init];
        _businessLab.font = [UIFont systemFontOfSize:12];
        _businessLab.textColor = [UIColor darkGrayColor];
        [self addSubview:_businessLab];
        _hitLab = [[UILabel alloc] init];
        _hitLab.font = [UIFont systemFontOfSize:12];
        _hitLab.textColor = [UIColor darkGrayColor];
        [self addSubview:_hitLab];
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(3);
            make.top.bottom.offset(0);
            make.height.equalTo(self.mas_height);
            //make.bottom.offset(-3);
            make.width.equalTo(self.mas_width).multipliedBy(0.33);
        }];
        [_atitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_imgView.mas_right).offset(10);
            make.right.offset(-5);
            make.top.offset(5);
        }];
        [_subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_imgView.mas_right).offset(5);
            make.top.equalTo(_atitleLab.mas_bottom).offset(20);
            
        }];
        [_businessLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_imgView.mas_right).offset(5);
            make.bottom.offset(-10);
        }];
        [_hitLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-10);
            make.centerY.equalTo(_businessLab.mas_centerY);
            // make.bottom.offset(-10);
        }];
        
        
    }
    return self;
    
}
- (void)setTotal:(Total *)total
{
    _total = total;
    [_imgView sd_setImageWithURL:[NSURL URLWithString:_total.img_path]];
    _atitleLab.text = _total.title;
    _subTitleLab.text = [NSString stringWithFormat:@"¥%@",_total.price];
    _businessLab.text = [NSString stringWithFormat:@"商家 :%@",_total.business];
    _hitLab.text = [NSString stringWithFormat:@"热度:%@",_total.hits];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
